import PureCompanyAdminList from '../components/company-list';
import * as CompanyAction from 'actions/company';
import { getFetchStatus } from 'actions/util';
import * as React from 'react';
import * as ReactRedux from 'react-redux';

const mapStateToProps = (state) => {
  return {
    fetching: getFetchStatus(state, CompanyAction.listByCurrentUser),
    companies: state.currentUserCompanyList
  };
};

class CompanyAdminList extends React.Component {
  componentDidMount() {
    this.props.dispatch(CompanyAction.listByCurrentUser());
  }

  render() {
    return <PureCompanyAdminList {...this.props}/>;
  }
}

export default ReactRedux.connect(mapStateToProps)(CompanyAdminList);
